package xuanke;

import java.util.Scanner;

public class TestSchoolSubjects {
    public void menu1() {
        System.out.println("欢迎使用选课系统" + "\n" + "菜单" + "\n" + "1.教师登录" + "\n" + "2.学生登录" + "\n");
    }

    public void menu2() {
        System.out.println("您已进入选课系统" + "\n" + "菜单" + "\n" + "1.选课" + "\n" + "2.退课" + "\n" );
    }

    public void reportError() {
        System.out.println("您的输入有误，请重新进入选课系统ֹ");
    }

    public void fengexian() {
        for (int i = 1; i <= 10; i++) {
            System.out.print("-----");
        }
        ;
        System.out.println();
    }

    public static void main(String[] args) {
        TestSchoolSubjects TS = new TestSchoolSubjects();
        Scanner input = new Scanner(System.in);
        Curriculums gaoshu = new Curriculums(1, "高数", "101教室", "8:00");
        Curriculums wuli = new Curriculums(2, "物理", "102教室", "13:00");
        Curriculums yuwen = new Curriculums(3, "语文", "201教室", "10:00");
        Curriculums xiandai = new Curriculums(4, "线代", "202教室", "15:00");
        Curriculums lisan = new Curriculums(5, "离散", "301教室", "19:00");
        Curriculums tiyu = new Curriculums(6, "体育", "操场", "9:00");
        Curriculums moren1[] = new Curriculums[6];
        Curriculums moren2[] = new Curriculums[6];
        Teachers Tea = new Teachers(1, "张三老师", "男", moren1);
        Students Std = new Students(1, "李四同学", "女", moren2);
        int x = 0;
        while (true) {
            TS.fengexian();
            if (x == 0) {
                System.out.println("欢迎使用选课系统" + "\n" + "还没有课程开设" + "\n" + "自动进入开课系统");
                TS.fengexian();
                System.out.println("可开课程为:" + "\n" + "0:" + gaoshu.curriculums + "1:" + wuli.curriculums +
                        "2:" + yuwen.curriculums + "3:" +  xiandai.curriculums + "4:" + lisan.curriculums + "5:"
                        + tiyu.curriculums);
                TS.fengexian();
                System.out.println("请输入开课号");
                int z = input.nextInt();
                Curriculums moren[] = { gaoshu, wuli, yuwen, xiandai, lisan, tiyu };
                Tea.openCurriculums(Tea, z, moren[z]);
                moren[z].curriculumsTeacher = "赵老师";
                TS.fengexian();
                System.out.println("是否继续进行操作?" + "\n" + "1.继续" + "\n" + "2.结束");
                TS.fengexian();
                x = input.nextInt();
                if (x == 1) {
                    continue;
                }
                TS.fengexian();
                break;
            } else {
                TS.menu1();
                TS.fengexian();
                x = input.nextInt();
                if (x == 1) {
                    System.out.println("正在开课");
                    TS.fengexian();
                    System.out.println("可开课程为:" + "\n" + "0:" + gaoshu.curriculums + "1:" + wuli.curriculums +
                            "2:" + yuwen.curriculums + "3:" +  xiandai.curriculums + "4:" + lisan.curriculums + "5:"
                            + tiyu.curriculums);
                    TS.fengexian();
                    System.out.println("请输入开课号");
                    int z = input.nextInt();
                    Curriculums moren[] = { gaoshu, wuli, yuwen, xiandai, lisan, tiyu };
                    Tea.openCurriculums(Tea, z, moren[z]);
                    moren[z].curriculumsTeacher = "赵";
                } else if (x == 2) {
                    TS.fengexian();
                    TS.menu2();
                    TS.fengexian();
                    int s = input.nextInt();
                    if (s == 1) {
                        TS.fengexian();
                        System.out.println("正在选课");
                        TS.fengexian();
                        System.out.println("可选课程为:" + "\n" + "0:" + gaoshu.curriculums + "1:" + wuli.curriculums +
                                "2:" + yuwen.curriculums + "3:" +  xiandai.curriculums + "4:" + lisan.curriculums + "5:"
                                + tiyu.curriculums);
                        TS.fengexian();
                        Curriculums moren[] = { gaoshu, wuli, yuwen, xiandai, lisan, tiyu };
                        int j = input.nextInt();
                        Std.choiceCurriculums(Std, j, moren[j]);
                    } else if (s == 2) {
                        System.out.println("正在退课");
                        TS.fengexian();
                        int p = input.nextInt();
                        Std.outCurriculums(Std, p);
                    } else {
                        TS.fengexian();
                        TS.reportError();
                        TS.fengexian();
                        break;
                    }
                    TS.fengexian();
                    System.out.println("本次选课已结束，请确认信息");
                    System.out.println("学生姓名：" + Std.name + "\n" + "所选课程：" + "\n");
                    for (int i = 0; i < 6; i++) {
                        if (Std.curriculums[i] == null) {
                            continue;
                        }
                        System.out.print(Std.curriculums[i].number + "｜" + Std.curriculums[i].curriculums
                                + "｜" + Std.curriculums[i].place + "｜" + Std.curriculums[i].Classtime + "｜"
                                + Std.curriculums[i].curriculumsTeacher + "\n");
                    }
                    TS.fengexian();
                } else {
                    TS.fengexian();
                    TS.reportError();
                    TS.fengexian();
                    break;
                }
            }
            ;
            System.out.println("是否继续进行操作?" + "\n" + "1.继续" + "\n" + "2.结束");
            TS.fengexian();
            int y = input.nextInt();
            if (y == 1) {
                continue;
            } else if (y == 2)
                break;
            else {
                TS.fengexian();
                TS.reportError();
                TS.fengexian();
                break;
            }
        }
        input.close();
    }

}
